package com.xbongbong.saas.help;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.help.FormDataHelp;
import com.xbongbong.paas.help.FormatDataHelp;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.formdata.pojo.dto.SaasAnalysisDataDTO;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2019/2/20 10:43
 * @since v1.0
 */
@Component
public class BaseHelp {

    @Resource
    private FormDataHelp formDataHelp;
    @Resource
    private FormatDataHelp formatDataHelp;

    /**
     * Saas获取单条业务数据
     *
     * @param formDataId   表单数据id
     * @param corpid       公司id
     * @param businessType 业务类型
     * @return 封装了数据的业务数据实体
     * @author chaoxiong.lei
     * @date 14:00 2019/1/22
     * @since v1.0
     **/
    public PaasFormDataEntityExt getFormData(Long formDataId, String corpid, Integer businessType) {
        return formDataHelp.getFormData(formDataId, corpid, businessType);
    }

    /**
     * saas特殊字段格式化
     *
     * @param saasAnalysisDataDTO 数据对象
     * @throws XbbException 抛出业务异常
     * @author haibin.zhang
     */
    public void formatData(SaasAnalysisDataDTO saasAnalysisDataDTO, JSONObject result) throws XbbException {
        formatDataHelp.formatData(saasAnalysisDataDTO, result);
    }

    /**
     * 测试用 TODO
     * @return
     */
    public String test() {
        return "2";
    }
}
